Skip to content

feat(preview): allow setting compression options #20612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

valadaptive
Copy link

Description

I noticed that the @polka/compression middleware doesn't compress WebAssembly files. While I intend to fix this upstream in @polka/compression itself, I think it's worth exposing the compression middleware options in Vite itself. I find the preview server useful for (roughly) profiling how long my application will take to load on slow connections, and hosts like GitHub Pages do compress WebAssembly.

I hope re-exporting the interface directly from @polka/compression isn't an issue--it seems to be done with the HTTP proxy options as well.

I can't seem to find the tests for the preview server--let me know what I should base the tests off of.

@bluwy
Copy link
Member

bluwy commented Aug 14, 2025

We usually try to avoid adding new options to not make the config too complex. Is there a specific option you're looking to toggle that we could do by default instead?

@valadaptive
Copy link
Author

If you'd prefer not to add compression options, you could just enable compressing WebAssembly files in the dev server (it may be worth going through and checking what has compressible: true in the mime-db package and making sure those are in the regex too)

@bluwy
Copy link
Member

bluwy commented Aug 14, 2025

Yeah I think that's reasonable to add. Maybe also worth upstreaming this to @polka/compression like you mention, but I think we can also do this in vite directly first.

We're currently using mrmime which doesn't have compressible data to use, but perhaps a manual test/check with mime-db locally with the regex is enough here. I skim through mime-db and it seems like the regex already covers most.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants